﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using EzDesk.DevHelper.DebugLibrary.Model;
using System.Xml.Linq;

namespace EzDesk.DevHelper.DebugLibrary
{
    public class EzDeskMessageInitial : EzDeskInitial, IEzDeskInitial
    {
        #region IEzDeskInitial Members

        void IEzDeskInitial.Initialize()
        {
            Debug.WriteLine("开始配置消息系统测试环境...");

            Guid msgAppId = Guid.NewGuid();

            Dictionary<string, string> domains = new Dictionary<string, string>()
            {
                {"GenericMobile", "localhost:4901"},
                {"DesktopClient", "localhost:5901"},
            };

            CreateBasicInfo(msgAppId, "Message", "消息", "通过消息应用，在公司内部互相发送通知的信息。", domains);

            //清除消息数据库
            EzDeskMessageDataContext msgDb = new EzDeskMessageDataContext();

            msgDb.ez_MessageFeeds.DeleteAllOnSubmit(msgDb.ez_MessageFeeds);
            msgDb.ez_MessageConfirms.DeleteAllOnSubmit(msgDb.ez_MessageConfirms);
            msgDb.ez_Messages.DeleteAllOnSubmit(msgDb.ez_Messages);
            msgDb.SubmitChanges();
            Debug.WriteLine("消息数据库已经清除");

            //更新消息发送模板
            InitialFeedsTemplate(msgAppId, "msgFeedTemplate.xml");

            Debug.WriteLine("消息发送模板已经更新");

            //添加消息发送的模板


        }

        void IEzDeskInitial.AddInitializeModule(IEzDeskInitial EzDeskMessageInitial)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
